<?php

$loop_count = 0;

function tarai($x, $y, $z)
{
    global $loop_count;
    ++$loop_count;

    if ($y < $x)
        return tarai(tarai($x-1, $y, $z),
                     tarai($y-1, $z, $x),
                     tarai($z-1, $x, $y));

    return $y;
}

echo tarai(12, 6, 0), "\n";
echo $loop_count, "\n";
